package com.itheima.tlias84.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.tlias84.controller.po.SelectLogPageParam;
import com.itheima.tlias84.dao.mapper.LogMapper;
import com.itheima.tlias84.service.dto.SelectLogDTO;
import com.itheima.tlias84.service.vo.PageVO;
import com.itheima.tlias84.utils.ResultUtil;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class LogController {

    @Resource
    LogMapper logMapper;

    @GetMapping("/log/page")
    public ResultUtil selectLogPage(SelectLogPageParam param) {
        Page<Object> page = PageHelper.startPage(param.getPage(), param.getPageSize());

        List<SelectLogDTO> list = logMapper.selectLogPage(param);

        PageVO<Object> pageVO = new PageVO<>();
        pageVO.setTotal(page.getTotal());
        pageVO.setRows(list);

        return ResultUtil.success(pageVO);
    }

}
